home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 18 / CU Amiga Magazine's Super CD-ROM 18 (1997)(EMAP Images)(GB)[!][issue 1998-01].iso / CUCD / Online / hsc / source / ugly / fname.h < prev    next >
Encoding:
C/C++ Source or Header  |  1997-11-02  |  4.7 KB  |  170 lines

  1. /*
  2.  * This source code is part of hsc, a html-preprocessor,
  3.  * Copyright (C) 1993-1997  Thomas Aglassinger
  4.  *
  5.  * This program is free software; you can redistribute it and/or modify
  6.  * it under the terms of the GNU General Public License as published by
  7.  * the Free Software Foundation; either version 2 of the License, or
  8.  * (at your option) any later version.
  9.  *
  10.  * This program is distributed in the hope that it will be useful,
  11.  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12.  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13.  * GNU General Public License for more details.
  14.  *
  15.  * You should have received a copy of the GNU General Public License
  16.  * along with this program; if not, write to the Free Software
  17.  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  18.  *
  19.  */
  20. /*
  21.  * ugly/fname.h
  22.  *
  23.  * header file for filename manipulaton functions
  24.  *
  25.  * (W) by Tommy-Saftwörx in 1994-97
  26.  *
  27.  */
  28.  
  29. #ifndef UGLY_FNAME_H
  30. #define UGLY_FNAME_H
  31.  
  32. #include "utypes.h"
  33. #include "expstr.h"
  34.  
  35. /*
  36.  * system depandant defines
  37.  */
  38.  
  39. /*
  40.  * MAX_FPATH         max. length of whole path
  41.  * MAX_FNAME         max. length of filename
  42.  * MAX_FEXT          max. length of file extension
  43.  * PATH_SEPARATOR    to separate diretories and devices
  44.  * DIR_SEPARATOR     to separate directories
  45.  * PARENT_DIR        to be inserted to refer to parent directory
  46.  * FNAME_IGNORE_CASE flag; ignore case within filenames
  47.  *
  48.  * CRLF_SHIT         0=OS uses single "\n" for EOL
  49.  */
  50.  
  51. #ifdef AMIGA                           /* AmigaOS */
  52. #define MAX_FPATH 256
  53. #define MAX_FNAME  31
  54. #define MAX_FEXT   30
  55. #define PATH_SEPARATOR    "/:"
  56. #define DIR_SEPARATOR     '/'
  57. #define PARENT_DIR        "/"
  58. #define FNAME_IGNORE_CASE 1
  59. #define SUGGEST_CRLF_SHIT 0
  60.  
  61. #elif defined RISCOS                   /* RiscOS */
  62. #define MAX_FPATH 255
  63. #define MAX_FNAME  32
  64. #define MAX_FEXT   32
  65. #define PATH_SEPARATOR    "/"
  66. #define DIR_SEPARATOR     '/'
  67. #define PARENT_DIR        "../"
  68. #define FNAME_IGNORE_CASE 1
  69. #define SUGGEST_CRLF_SHIT 0
  70.  
  71. #elif defined NEXTSTEP                 /* NeXTStep */
  72. #define MAX_FPATH 254
  73. #define MAX_FNAME 254
  74. #define MAX_FEXT  253
  75. #define PATH_SEPARATOR    "/"
  76. #define DIR_SEPARATOR     '/'
  77. #define PARENT_DIR        "../"
  78. #define FNAME_IGNORE_CASE 0
  79. #define SUGGEST_CRLF_SHIT 0
  80.  
  81. #elif defined BEOS                     /* BeOS */
  82. #define MAX_FPATH 254
  83. #define MAX_FNAME  64
  84. #define MAX_FEXT   63
  85. #define PATH_SEPARATOR    "/"
  86. #define DIR_SEPARATOR     '/'
  87. #define PARENT_DIR        "../"
  88. #define FNAME_IGNORE_CASE 1
  89. #define SUGGEST_CRLF_SHIT 0
  90.  
  91. #elif defined UNIX                     /* Weenix */
  92. #define MAX_FPATH 254
  93. #define MAX_FNAME 254
  94. #define MAX_FEXT  253
  95. #define PATH_SEPARATOR    "/"
  96. #define DIR_SEPARATOR     '/'
  97. #define PARENT_DIR        "../"
  98. #define FNAME_IGNORE_CASE 0
  99. #define SUGGEST_CRLF_SHIT 0
  100.  
  101. #elif defined WINNT                    /* bullshit 1 */
  102. #define MAX_FPATH 254
  103. #define MAX_FNAME 254
  104. #define MAX_FEXT  253
  105. #define PATH_SEPARATOR    "\\:"
  106. #define DIR_SEPARATOR     '\\'
  107. #define PARENT_DIR        "..\\"
  108. #define FNAME_IGNORE_CASE 1
  109. #define SUGGEST_CRLF_SHIT 1
  110.  
  111. #define MSDOS 1 /* isn't this nasty? */
  112.  
  113. #elif defined MSDOS                    /* bullshit 2 */
  114. #define MAX_FPATH 128
  115. #define MAX_FNAME   8
  116. #define MAX_FEXT    3
  117. #define PATH_SEPARATOR    "\\:"
  118. #define DIR_SEPARATOR     '\\'
  119. #define PARENT_DIR        "..\\"
  120. #define FNAME_IGNORE_CASE 1
  121. #define SUGGEST_CRLF_SHIT 1
  122.  
  123. #else
  124. #error "Operating system not supported: filename-functions"
  125. #endif
  126.  
  127. /* if CRLF_SHIT has not been set by user, use OS-default */
  128. #ifndef CRLF_SHIT
  129. #define CRLF_SHIT SUGGEST_CRLF_SHIT
  130. #endif
  131.  
  132. /* strcmp() for filenames: case-sensitive or not */
  133. #if FNAME_IGNORE_CASE
  134. #define fnamecmp(a,b) strcmp((a),(b))
  135. #define fnamencmp(a,b,n) strncmp((a),(b),(n))
  136. #else
  137. #define fnamecmp(a,b) upstrcmp((a),(b))
  138. #define fnamencmp(a,b,n) upstrncmp((a),(b),(n))
  139. #endif
  140.  
  141. #define ok_fnl_fpath(x) ((BOOL)(estrlen(x)<=MAX_FPATH))
  142. #define ok_fnl_fname(x) ((BOOL)(estrlen(x)<=MAX_FNAME))
  143. #define ok_fnl_fext(x)  ((BOOL)(estrlen(x)<=MAX_FEXT))
  144.  
  145. /*
  146.  * external function prototypes
  147.  */
  148.  
  149. #ifndef NOEXTERN_UGLY_FNAME_H
  150.  
  151. extern BOOL get_fext(EXPSTR * dest, CONSTRPTR fn);
  152. extern BOOL get_fname(EXPSTR * dest, CONSTRPTR fn);
  153. extern BOOL get_fpath(EXPSTR * dest, CONSTRPTR fn);
  154. extern BOOL get_fsdir(EXPSTR * dest, CONSTRPTR fn);
  155. extern BOOL get_relfname(EXPSTR * dest, STRPTR absn, STRPTR curp);
  156.  
  157. extern BOOL clr_fext(EXPSTR * dest);
  158. extern BOOL set_fext(EXPSTR * dest, CONSTRPTR newext);
  159. extern BOOL app_fext(EXPSTR * dest, CONSTRPTR newext);
  160. extern BOOL set_fnameIdx(EXPSTR * dest, int idx);
  161. extern BOOL link_fname(EXPSTR * dest, STRPTR dir, STRPTR fn);
  162. extern BOOL link_envfname(EXPSTR * dest, STRPTR env, STRPTR dir, STRPTR fn);
  163.  
  164. extern STRPTR tmpnamstr(STRPTR prefix);
  165.  
  166. #endif
  167.  
  168. #endif
  169.  
  170.